package com.xg.controller.boss;

import com.xg.common.request.UsedCarReq;
import com.xg.common.result.ApiResult;
import com.xg.common.util.PageUtil;
import com.xg.common.util.PageUtils;
import com.xg.entity.UsedCar;
import com.xg.service.IUsedCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 给api-boss服务暴露接口的类
 */
@RestController
public class CarController {

    @Autowired
    private IUsedCarService carService;

    /**
     * 车辆列表
     * @param params
     * @return
     */
    @RequestMapping("/car/list")
    public PageUtils findCarList(@RequestParam Map<String,Object> params){
        PageUtils page = carService.queryPage(params);
        return page;

    }

    /**
     * newCar列表
     * @Author: JiaDeHao
     * @Date: 15:30 2023/4/4
     */
    @RequestMapping("/car/listNew")
    PageUtil<UsedCar> findCarListNew(@RequestParam Map<String, Object> params){
        return carService.findCarListNew(params);
    }

    /**
     * 车辆新增
     * @Author: JiaDeHao
     * @Date: 14:28 2023/4/3
     */
    @RequestMapping("/car/save")
    ApiResult saveUsedCar(@RequestBody UsedCar usedCar){
        return carService.saveUsedCar(usedCar);
    }

    /**
     * 车辆删除
     * @Author: JiaDeHao
     * @Date: 14:28 2023/4/3
     */
    @RequestMapping("/car/delete")
    ApiResult deleteUsedCar(@RequestParam("ids") List<Integer> ids){
        return carService.deleteUsedCar(ids);
    }

    @RequestMapping("/car/info")
    ApiResult<UsedCar> selectUsedCarInfo(@RequestParam("usedCarId") Integer usedCarId){
        return carService.selectUsedCarInfo(usedCarId);
    }

    /**
     * 车辆信息审核
     * @param ids
     * @return
     */
    @RequestMapping("/car/audit")
    ApiResult auditUsedCar(@RequestBody UsedCarReq usedCarReq){
        return carService.auditUsedCar(usedCarReq);
    }
}
